# -*- coding: utf-8 -*-

"""
DateTime   : 2020/12/22 21:22
Author     : ZhangYafei
Description: 
"""
import random

result = {}

user_list = ["詹姆斯", "张亚飞", "李云龙"]

# 1. 生成一副扑克牌
total_poke_list = [("小王", 14), ("大王", 15)]
color_list = ["红桃", "黑桃", "方片", "梅花"]
num_list = []
for num in range(1, 14):
    num_list.append(num)
for color in color_list:
    for num in num_list:
        item = (color, num,)
        total_poke_list.append(item)

# 2. 发牌 -> ["zhangyafei","张亚飞","李云龙"]
for user in user_list:
    # 给用户发第一张牌
    score = 0
    index = random.randint(0, len(total_poke_list) - 1)
    poke = total_poke_list.pop(index)  # ("花色",值)
    # JQK表示 0.5 点
    value = poke[1]
    if poke[1] > 10:
        value = 0.5
    score += value
    print("给{}发的牌：{}{}，此刻所有牌面值总和:{}".format(user, poke[0], poke[1], score))

    # 用户选择是否继续要
    while True:
        choice = input("是否继续要牌(Y/N)？")
        choice = choice.upper()

        # 用户输入的不是Y/N/y/n
        if choice not in {"Y", "N"}:
            print("输入错误，请重新输入。")
            continue

        # 用户输入N，不继续要牌了
        if choice == "N":
            print("{}不要拍了".format(user))
            break

        # 继续要拍（再随机抽取一张）
        index = random.randint(0, len(total_poke_list) - 1)
        poke = total_poke_list.pop(index)
        value = poke[1]
        if poke[1] > 10:
            value = 0.5
        score += value

        print("给{}发的牌：{}{}，此刻所有牌面值总和:{}".format(user, poke[0], poke[1], score))

        # 大于11点，则用户爆了且分值变为0
        if score > 11:
            print("用户{}爆了".format(user))
            break

    result[user] = score

print(result)